package cn.kgc.web.utils;

import cn.hutool.json.JSONUtil;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author: 课工场
 * @since 2023/9/27
 */
public class ResponseUtil {

    public static  void  writeJson(Object data, HttpServletResponse response){
        response.setContentType("application/json;charset=utf-8");
        PrintWriter writer = null;
        try {
            writer = response.getWriter();
            String str = JSONUtil.toJsonStr(data);
            writer.write(str);
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
